import Vue from 'vue'
//
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css 全局引入

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon   //导入SVG  icon 图标
import '@/permission' // permission control  //页面路由权限控制

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// 模拟请求
/* if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
} */

// set ElementUI lang to EN  设置语言
// Vue.use(ElementUI, { locale })
Vue.use(ElementUI)
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false
// 配置环境变量
// console.log(process.env.VUE_APP_BASE_API，'测试环境变量' )
// 按需导入所有 放到didraetives
import * as didraetives from './didraetive'
console.log(Object.keys(didraetives))
Object.keys(didraetives).forEach(key => {
  // 全局注册
  Vue.directive(key, didraetives[key])
})
/* Vue.directive('imgerror', {
  inserted(el, binding) {
    el.onerror = () => {
      console.log('图片加载失败')
      el.src = binding.value
    }
  }
}) */

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
